package edu.hawaii.duedates.wicket;


import org.apache.wicket.Request;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebSession;
import edu.hawaii.duedates.DueDates;

/**
 * Each user of DueDates is given his own instance of the program that holds his information.
 * 
 * @author robin
 *
 */
public class DueDatesSession extends WebSession {
  
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  
  private static DueDates dd = new DueDates();
  
  /** Stores an interval input. */
  private double intervalInput;
  
  /** Stores a within variable. */
  private int withinValue = 360;
  
  /** Stores a within variable for all libraries. */
  private int withinAll = 360;
  
  /**Stores a boolean value if all libraries are to be displayed. */
  private boolean isAll = true;
  
  /** Stores an error string. */
  private String error = "";
  
  /** Stores the sort option. */
  private String sOption = "";
  
  /**
   * Create a new session for the user. 
   * 
   * @param application This application.
   * @param request The request.
   */
  public DueDatesSession(WebApplication application, Request request) {
    super(request);
  }
  
  /**
   * Return duedates for this user.
   * 
   * @return DueDates.
   */
  public DueDates getDueDates() {
    return dd;
  }
  
  /**
   * Set the users interval input.
   * 
   * @param intervalInput2 The interval to be input.
   */
  public void setInterval(double intervalInput2) {
    this.intervalInput = intervalInput2;
  }
  
  /**
   * Gets the users interval.
   * 
   * @return The user's interval.
   */
  public double getInterval() {
    return this.intervalInput;
  }
  
  /**
   * Gets the within variable.
   * 
   * @return The user's variable.
   */
  public int getWithin() {
    return this.withinValue;
  }
  
  /**
   * Sets the within variable.
   * 
   * @param withinVariable The within variable.
   */
  public void setWithin(int withinVariable) {
    System.out.println("Within Value = " + withinVariable);
    if (withinVariable == 0) {
      this.withinValue = 360;
    }
    else {
      this.withinValue = withinVariable;
    }
  }
  
  /**
   * Sets an error message.
   * 
   * @param error The error message.
   */
  public void setErrorMessage(String error) {
    this.error = error;
  }
  
  /**
   * Gets the error message.
   * 
   * @return The error message.
   */
  public String getErrorMessage() {
    return this.error;
  }
  
  /**
   * Sets the sort option.
   * 
   * @param sort The sort option.
   */
  public void setSortOption(String sort) {
    this.sOption = sort;
  }
  
  /**
   * Gets the sort option.
   * 
   * @return The sort option.
   */
  public String getSortOption() {
    return this.sOption;
  }

  /**
   * @param withinAll the withinAll to set.
   */
  public void setWithinAll(int withinAll) {
    this.withinAll = withinAll;
  }

  /**
   * @return the withinAll.
   */
  public int getWithinAll() {
    return withinAll;
  }
  
  /**
   * Sets if the All Libraries are to be displayed or not.
   * 
   * @param isAll if it is all or not.
   */
  public void setIsAllLib(boolean isAll) {
    this.isAll = isAll;
  }
  
  /**
   * Gets info if All Librarires are to be displayed or not.
   * 
   * @return isAll boolean value
   */
  public boolean isAllLib() {
    return this.isAll;
  }
 
}
